package cc.mrbird.febs.suggest.service.impl;

import cc.mrbird.febs.common.domain.QueryRequest;
import cc.mrbird.febs.common.utils.SortUtil;
import cc.mrbird.febs.suggest.dao.SuggestMapper;
import cc.mrbird.febs.suggest.domain.BusBean;
import cc.mrbird.febs.suggest.domain.SuggestBean;
import cc.mrbird.febs.suggest.service.SuggestService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("SuggestService")
public class SuggestServiceImpl extends ServiceImpl<SuggestMapper, SuggestBean> implements SuggestService {
    @Override
    public IPage<SuggestBean> findSuggestDetail(SuggestBean suggestBean, QueryRequest request) {
        try {
            Page<SuggestBean> page = new Page<>();
            SortUtil.handlePageSort(request, page);
            return this.baseMapper.findSuggestDetail(page, suggestBean);
        } catch (Exception e) {
            log.error("查询异常", e);
            return null;
        }
    }

    @Override
    public IPage<SuggestBean> findSuggestAll(SuggestBean suggestBean, QueryRequest request) {
        try {
            Page<SuggestBean> page = new Page<>();
            SortUtil.handlePageSort(request, page);
            return this.baseMapper.findSuggestAll(page, suggestBean);
        } catch (Exception e) {
            log.error("查询异常", e);
            return null;
        }
    }

    @Override
    public List<BusBean> listBusHour() {
        return this.baseMapper.listBusHour();
    }

    @Override
    public List<BusBean> listBusTopN() {
        return this.baseMapper.listBusTopN();
    }

    @Override
    public List<BusBean> listStation() {
        return this.baseMapper.listStation();
    }

    @Override
    public List<BusBean> listBusNum() {
        return this.baseMapper.listBusNum();
    }

    @Override
    public List<BusBean> listStationTopN() {
        return this.baseMapper.listStationTopN();
    }
}
